<template>
  <section v-loading="loading">
    <form class="box" method="post" action="/upload-web.php" enctype="multipart/form-data" novalidate>
      <input name="files" type="file" @change="getFile($event)">
    </form>
  </section>
</template>

<script>
  import axios from 'axios'
  export default {
    name: "index",
    data() {
      return {
        loading:false
      }
    },
    methods:{
      getFile(e) {
        this.loading=true
        let file = e.target.files[0];
        let param = new FormData(); //创建form对象XMLHttpRequest   ajax
        param.append('files',file);//通过append向form对象添加数据
        let config = {
          headers:{'Content-Type':'multipart/form-data'}
        }; //添加请求头
        axios.post('https://img.fsthz.com/upload-web.php',param,config)
          .then(response=>{
            this.loading=false
            console.log(response.data)
            this.$emit('get',response.data)
          })
      },
      update(e){
      }
    }
  }
</script>

<style scoped>

</style>
